package cn.wolfcode.rabc.domain;



import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.ToString;
import org.springframework.stereotype.Component;
import java.util.HashMap;

@Component
public class Department {
    /** 部门ID*/
    private Long id;

    /** 部门名称*/
    private String name;

    /** 部门英文*/
    private String sn;

    private String json;

    public String getJson() throws JsonProcessingException {
        // 将对象转成JSON 字符串格式
        HashMap<String, Object> json = new HashMap<>();
        json.put("id",id);
        json.put("name",name);
        json.put("sn",sn);
        ObjectMapper obj =new ObjectMapper();
        return obj.writeValueAsString(json);
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    @Override
    public String toString() {
        return "Department{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", sn='" + sn + '\'' +
                ", json='" + json + '\'' +
                '}';
    }
}